package com.itzb.asone.batch.job.asone.task;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.util.StopWatch;

import com.itzb.asone.system.service.IMessageService;

public class AsOneTask {
	
	
	private Logger logger = Logger.getLogger(getClass()); 
	
	private JobParametersBuilder jobParameterBulider;
	private JobLauncher jobLauncher;  
	private Job asOneJob;  
	private IMessageService messageService;
	
	public void execute() throws Exception {  
		
		logger.info("Task");
		
		JobParametersBuilder jobParameterBulider = new JobParametersBuilder();
		StopWatch sw = new StopWatch();  
	    sw.start();  
	    
	    jobParameterBulider.addString("date",new Date().toString());
	    jobLauncher.run(asOneJob, jobParameterBulider.toJobParameters());  
	    sw.stop(); 
	}
	
	

	public JobParametersBuilder getJobParameterBulider() {
		return jobParameterBulider;
	}

	public void setJobParameterBulider(JobParametersBuilder jobParameterBulider) {
		this.jobParameterBulider = jobParameterBulider;
	}

	public JobLauncher getJobLauncher() {
		return jobLauncher;
	}

	public void setJobLauncher(JobLauncher jobLauncher) {
		this.jobLauncher = jobLauncher;
	}

	public Job getAsOneJob() {
		return asOneJob;
	}

	public void setAsOneJob(Job asOneJob) {
		this.asOneJob = asOneJob;
	}

	public IMessageService getMessageService() {
		return messageService;
	}

	public void setMessageService(IMessageService messageService) {
		this.messageService = messageService;
	}
	
	
}
